<?php
class SampleShell extends AppShell {
	public $uses = array('User', 'BackupUsers');
	public function main() {
		$this->User->unbindModel(array('hasMany' => array('Post')));
		$users = $this->User->find ( 'all', array (
				'fields' => array('id', 'username', 'password', 'group_id', 'fullname', 'created'),
				'conditions' => array('User.backed_up' => 0)
		) );
		
		if(count($users) > 0){
			foreach ($users as $user){
				$userBackUp = $this->BackupUsers->create();
				
				$userBackUp['id'] = $user['User']['id'];
				$userBackUp['username'] = $user['User']['username'];
				$userBackUp['password'] = $user['User']['password'];
				$userBackUp['group_id'] = $user['User']['group_id'];
				$userBackUp['fullname'] = $user['User']['fullname'];
				$userBackUp['created'] = $user['User']['created'];
				
				$this->BackupUsers->save($userBackUp);
				
				$user['User']['backed_up'] = 1;
				$this->User->save($user);
			}
		}
// 		$this->out(print_r($userBackUp));
	}
}